﻿using CommonInitializer;
using TestService.Infrastructure;
using Microsoft.EntityFrameworkCore.Design;

namespace TestService.WebAPI.Controllers;
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<TestDbContext>
{
    /// <summary>
    /// https://www.bilibili.com/video/BV1pK41137He?p=132&vd_source=669535664bde6a6b9edc44549e0e21ad
    /// </summary>
    /// <param name="args"></param>
    /// <returns></returns>
    public TestDbContext CreateDbContext(string[] args)
    {
        // 创建并配置 DbContextOptionsBuilder 实例
        var optionsBuilder = DbContextOptionsBuilderFactory.Create<TestDbContext>();
        return new TestDbContext(optionsBuilder.Options, null);
    }
}